package com.maozzi.web.controller.rest;

import com.maozzi.api.es.EsService;
import com.maozzi.api.es.model.EsUserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 搜索 controller
 *
 * @author maozi
 */
@Slf4j
@RestController
@RequestMapping("/rest/search")
public class SearchController {
    @Resource
    private EsService esService;

    /**
     * 测试搜索
     *
     * @param keyword 搜索关键字
     * @return 返回
     */
    @GetMapping("/get.json")
    public List<EsUserDTO> get(@RequestParam(required = false) String keyword) {
        List<EsUserDTO> list1 = esService.searchByTemplate(keyword);
        log.info("测试搜索-----list1=" + list1.toString());
        List<EsUserDTO> list2 = esService.searchByRepo(keyword);
        log.info("测试搜索-----list2=" + list2.toString());
        return new ArrayList<>();
    }
}
